let a = [10, 7, 5, 4]
function foo (a) {
    let temp = 0
    for(let i = 0; i< 3 ; i++) {
        // console.log(a[i])
        if (a[temp] < a[i+1]) {
            temp = i
        }
    }
    // console.log(temp)
    switch(temp) {
        case 0:
        a[0] = a[0] -3
        a[1] +=1
        a[2] +=1
        a[3] +=1
        break;
        case 1:
        a[1] = a[1] -3
        a[0] +=1
        a[2] +=1
        a[3] +=1
        break;
        case 2:
        a[2] = a[2] -3
        a[1] +=1
        a[0] +=1
        a[3] +=1
        break;
        default:
        a[3] = a[3] -3
        a[1] +=1
        a[2] +=1
        a[0] +=1
        break;
    }
    return a
}

for (let i = 0; i < 70; i++) {
    foo(a)
}
console.log(foo(a))